package com.gao.jacksonconfig.config;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.springframework.boot.jackson.JsonComponent;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @author GaoXi
 * @date 2022/3/1 21:21
 */
@JsonComponent
public class CustomJsonDeserializer extends StdDeserializer<BigDecimal> {
    protected CustomJsonDeserializer() {
        super(BigDecimal.class);
    }

    @Override
    public BigDecimal deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
        return jsonParser.getDecimalValue().add(new BigDecimal(10));
    }
}
